//
//  XSquareNews.swift
//  WeiBoReDo
//
//  Created by 放学跟鸽走 on 2017/4/16.
//  Copyright © 2017年 放学跟鸽走. All rights reserved.
//

import UIKit

class XSquareNews: NSObject {
    
    /// 鸽友圈显示名称
    var tpName:String?//	明林鸽舍

    //头像地址
    var head:String?//	http://news.chinaxinge.com/gyq/images/nophoto.gif
    /// 鸽友圈id
    var id:Int = 0 //	124636
    
    /// 详情中用到此字段，只是小写了一下首字母，此字段不用被外部使用
//   @objc private var content:String?{
//        didSet{
//            self.Content = content
//        }
//    }

    /// 内容
    var Content:String?{
        didSet{
//            print(Content)
            Content = Content?.replacingOccurrences(of: "[wx]", with: "[微笑]")
            Content = Content?.replacingOccurrences(of: "[mg]", with: "[鲜花]")
            Content = Content?.replacingOccurrences(of: "[aj]", with: "[可爱]")
            Content = Content?.replacingOccurrences(of: "[kun]", with: "[困]")
            Content = Content?.replacingOccurrences(of: "[xx]", with: "[嘻嘻]")
            Content = Content?.replacingOccurrences(of: "[shuai]", with: "[笑cry]")
            Content = Content?.replacingOccurrences(of: "[ax]", with: "[爱你]")
            Content = Content?.replacingOccurrences(of: "[dk]", with: "[笑cry]")
            Content = Content?.replacingOccurrences(of: "[fd]", with: "[笑cry]")
            Content = Content?.replacingOccurrences(of: "[fn]", with: "[怒]")
            Content = Content?.replacingOccurrences(of: "[xs]", with: "[笑cry]")
            Content = Content?.replacingOccurrences(of: "[fw]", with: "[笑cry]")
            
        }
    }
    /// 话题ID
    var cls_id:Int = 0 //	0
    /// 话题名称
    var cls_title:String?//春赛时刻 •
    /// 用户IDs
    var userId:Int = 0 //	518588
    /// 用户名
    var userName:String?//	俯瞰大地
    /// 发贴人地址
    var address:String?
    /// 是否显示地址
    var isshow_address:Int = 0 //	0
    
    /// 经纬度
    var lng:String?	//119.1123null
    /// 经纬度
    var lat:String?	//32.//null
    /// 来源
    var addFlag:String?//	来自PC
    /// 时间
    var addtime:String?//	7秒前

   
    /// 转发数
    var forwardNum:String?//	转发
    /// 评论数
    var commentNum:String?//	评论
    /// 赞
    var likesNum:String?//	赞

    /// 转发的ID
    var forwardId:Int = 0 //	0
    /// 大图
    var media_Src:String?//
    /// 缩略图
    var media_small_src:String?
    
    
    ///	0代表图，1代表视频
    var media_tp:Int = 0
    
    
    /// 转发json
    //{"id":124627,"Content":"3EA\u9002\u5408\u6674\u5929\u6BD4\u8D5B\u3002","tpName":"\u6CA7\u5317\u7231\u7FBD"}
    var forward:String?
    
    var forwardContent:XSquareRetweetNews?
    
    //[{"id":1308466,"Content":"\u4E94\u74E3\u5417","userId":605665,"username":"\u6E05\u6CB3\u7389\u826F","Newsid":124473,"replayUserid":0,"replayUsername":"","Addtime":"2017-4-15 20:02:51","Islike":0,"Replyid":0}]
    /// 评论json
    var reply:String?{
        didSet{
            replyArray = NSArray.yy_modelArray(with: XSquareReply.self, json: likes ?? "") as? [XSquareReply]
        }
    }
    
    /// 评论人信息列表
    var replyArray:[XSquareReply]?
    
    /// 赞的人
    //[{"id":1311437,"Content":"","userId":372521,"username":"lzy770124","Newsid":124630,"replayUserid":0,"replayUsername":"","Addtime":"2017-4-16 13:09:10","Islike":1,"Replyid":0},]
    /// 点赞json
    var likes:String?
    {
        didSet{
            likeArray = NSArray.yy_modelArray(with: XSquareReply.self, json: likes ?? "") as? [XSquareReply]
//            print(likeArray)
        }
    }
    /// 点赞人信息列表
    var likeArray:[XSquareReply]?
    
    override var description: String{
        return yy_modelDescription()
    }
    
    /// 类函数 -> 告诉第三方框架 YY_Model 如果遇到数组类型的属性，数组中存放的对象是什么类？
    /// NSArray 中保存对象的类型通常是 `id` 类型
    /// OC 中的泛型是 Swift 推出后，苹果为了兼容给 OC 增加的
    /// 从运行时角度，仍然不知道数组中应该存放什么类型的对象
//    class func modelContainerPropertyGenericClass() -> [String: AnyClass] {
//        return ["likes": XSquareReply.self]
//    }
    
}
